import 'package:flutter/material.dart';
import 'package:flutter_changdian_football/pages/mine/my_concerns/my_concerns_controller.dart';
import 'package:flutter_changdian_football/routers/app_routes.dart';
import 'package:flutter_changdian_football/utils/custom_constant.dart';
import 'package:flutter_changdian_football/utils/pull/pull_smart_refresher.dart';
import 'package:flutter_changdian_football/utils/str_utils.dart';
import 'package:flutter_changdian_football/widget/extended_image_slide_widget.dart';
import 'package:flutter_changdian_football/widget/screenutil/custom_screenutil.dart';
import 'package:get/get.dart';

// 我的关注
class MyConcernsPage extends StatelessWidget {
  const MyConcernsPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        centerTitle: true,
        backgroundColor: const Color(0xffF8FAF9),
        elevation: 0,
        title: Text(
          '我的关注',
          style: TextStyle(fontSize: 16.sp, color: const Color(0xff333333)),
        ),
        iconTheme: const IconThemeData(
          color: Color(0xff333333)
        ),
      ),
      body: GetBuilder<MyConcernsController>(
        init: MyConcernsController(),
        builder: (myConcernsController) {
          return RefreshWidget<MyConcernsController>(
            child: ListView.separated(
              itemCount: myConcernsController.userInterestModelList.length,
              physics: const BouncingScrollPhysics(),
              separatorBuilder: (context, index) {
                return Container(
                  width: double.infinity,
                  height: 1.w,
                  color: const Color(0xffF8FAF9),
                  margin: EdgeInsets.only(left: 75.w),
                );
              },
              itemBuilder: (BuildContext context, int index) {
                return GestureDetector(
                  behavior: HitTestBehavior.translucent,
                  onTap: () {
                    Get.toNamed(AppRoutes.playerInfo, parameters: {
                      'type': CustomConstant.USER_JB_INFO,
                      'queriedUserId': '${myConcernsController.userInterestModelList[index].focusedUserId ?? ''}'
                    });
                  },
                  child: Container(
                    padding: EdgeInsets.symmetric(vertical: 15.w, horizontal: 17.w),
                    child: Row(
                      children: [
                         
                          SizedBox(
                            width: 46.w,
                            height: 46.w,
                            child: ClipRRect(
                              borderRadius: BorderRadius.circular(46.r),
                              child: Image.network(myConcernsController.userInterestModelList[index].imgUrl ?? '', fit: BoxFit.fill,),
                            ),
                          ),
                          
                        SizedBox(width: 12.w,),
                          
                        Expanded(
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              SizedBox(
                                child: Row(
                                  children: [
                                    Flexible(
                                      child: Text(myConcernsController.userInterestModelList[index].nickname ?? '', style: TextStyle(fontSize: 15.sp, fontWeight: FontWeight.w500, color: const Color(0xff333333)), maxLines: 1, overflow: TextOverflow.ellipsis,),
                                    ),
                                    SizedBox(width: 6.w,),
                                    SizedBox(
                                      width: 12.w,
                                      height: 12.w,
                                      child: Image.asset(StrUtils.getSexImage(myConcernsController.userInterestModelList[index].sex ?? 0)),
                                    )
                                  ],
                                ),
                              ),
                          
                              SizedBox(height: 4.w,),
                          
                              SizedBox(
                                width: 69.w,
                                height: 18.w,
                                child: Image.asset(StrUtils.getLevelImage(myConcernsController.userInterestModelList[index].grade ?? 1)),
                              )
                            ],
                          ),
                        ),
                          
                        Container(
                          constraints: BoxConstraints(
                            maxHeight: 18.w,
                            maxWidth: 140.w
                          ),
                          child: ListView.separated(
                            itemCount: myConcernsController.userInterestModelList[index].goodPosition?.length ?? 0,
                            shrinkWrap: true,
                            scrollDirection: Axis.horizontal,
                            physics: const BouncingScrollPhysics(),
                            separatorBuilder: (context, subIndex) {
                              return SizedBox(width: 4.w,);
                            },
                            itemBuilder: (BuildContext context, int subIndex) {
                              return Container(
                                decoration: BoxDecoration(
                                  color: StrUtils.getColorByCode(myConcernsController.userInterestModelList[index].goodPosition?[subIndex].positionSortCode).withOpacity(0.1),
                                  borderRadius: BorderRadius.circular(15.r)
                                ),
                                padding: EdgeInsets.symmetric(vertical: 2.w, horizontal: 9.w),
                                child:  Text(myConcernsController.userInterestModelList[index].goodPosition?[subIndex].subdivisionPosition ?? '', style: TextStyle(fontSize: 10.sp, color: StrUtils.getColorByCode(myConcernsController.userInterestModelList[index].goodPosition?[subIndex].positionSortCode))),
                              );
                            },
                          ),
                        )
                      ],
                    ),
                  ),
                );
              },
            ),
          );
        }
      ),
    );
  }
}